﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Globalization;
using Public;


namespace WebsiteAdmin.Salomon.ProInfo.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class SeriesInsert : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int rtn = 0;
            if (Cookie.AdminLoginName != null || Cookie.AdminLoginName != "")
            {
                int txbCatID = Convert.ToInt32(context.Request["CatID"].Trim(), CultureInfo.InvariantCulture);

                string txbSerTitle = context.Request["SerTitle"].Trim();
                string txbImgURL = context.Request["ImgURL"].Trim();
                string txbDescription = context.Request["Description"].Trim();
                int txbSortBy = Convert.ToInt32(context.Request["SortBy"].Trim(), CultureInfo.InvariantCulture);	//显示顺序

                rtn = DoInsert(
                    txbCatID,
                    txbSerTitle,
                    txbDescription,
                    txbImgURL,
                    txbSortBy
                );
            }
            context.Response.Write((rtn == 1) ? "{ \"Done\": \"Success\" }" : "{ \"Done\": \"Failed\" }");
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        private static int DoInsert(
                int txbCatID,
                string txbSerTitle,
                string txbDescription,
                string txbImgURL,
                int txbSortBy
            )
        {
            return
                Bll.Series.Insert(
                    Global.ConSalomon,
                    txbCatID,
                    txbSerTitle,
                    txbDescription,
                    txbImgURL,
                    txbSortBy
                );
        }

    }
}
